
//
//  YYTool.swift
//  LoveLife
//
//  Created by 杨阳 on 16/9/6.
//  Copyright © 2016年 yangyang. All rights reserved.
//

import UIKit

//屏幕尺寸
let screenW = UIScreen.mainScreen().bounds.size.width
let screenH = (UIScreen.mainScreen().bounds.size.height - 64)//优先级


//给UIColor添加一个扩展
extension UIColor {
    //扩展一个类方法
    static func RGBA(red:CGFloat,_ green:CGFloat,_ blue:CGFloat,_ alpha:CGFloat = 1) ->UIColor {
        return UIColor(red: red / 255.0, green: green / 255.0, blue: blue / 255.0, alpha: alpha)
    }
    
    
    static func randomColor(alpha: CGFloat) -> UIColor{
        let red = CGFloat(Double(arc4random_uniform(256))/255.0)
        let green = CGFloat(Double(arc4random_uniform(256))/255.0)
        let blue = CGFloat(Double(arc4random_uniform(256))/255.0)
        
        return UIColor(red: red, green: green, blue: blue, alpha: alpha)
        
    }

}

func showAlert1(controller: UIViewController,message:String,completion:(()->())?) {
    
    let alertController = UIAlertController.init(title: nil, message: message, preferredStyle: .Alert)
    
    let action = UIAlertAction.init(title: "确定", style: .Default) { (_) in
        
        if completion != nil{
            
            completion!()
        }
    }
    alertController.addAction(action)
    controller.presentViewController(alertController, animated: true, completion: nil)
   
    
}


















